<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>${appname}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<%@ include file="/WEB-INF/view/common/css_js_ztree.jsp"%>
<script type="text/javascript">
	$(function() {
		$("#inputForm").checkForm(setRsAndChech);
		$('#inputForm').ajaxForm({
			url : _ctx + "/pub/sysmgr/authmgr/update_right.do",
			type : "post",
			dataType : "json",
			beforeSubmit: function(){
	        	var checkReturn = $('#inputForm').checkForm(null,false);
	        	if(checkReturn){
	        		$("#sbmBtn").attr("disabled","disabled");
	        	}
		       return checkReturn;
	        },
			clearForm : false,
			resetForm : false,
			success : function(resp) {
				if (resp.status == '1') {
					parent.ui.msg(resp.msg, 1);
					ui.go(_ctx + '/pub/sysmgr/authmgr/right_list.do');
				} else {
					parent.ui.msg(resp.msg, 0);
					$("#sbmBtn").removeClass("disabled").attr("disabled", null);
				}
			},
			error : function(resp) {
				parent.ui.msg('请求发送失败', 0);
				$("#sbmBtn").removeClass("disabled").attr("disabled", null);
			}
		});
	});
	var setting = {
		view : {
			selectedMulti : false,
			showIcon : true,
			fontCss : getFont
		},
		check : {
			enable : true
		},
		data : {
			simpleData : {
				enable : true
			}
		}
	};
	var zNodes = ${resourceData};
	var zTree;
	$(document).ready(function() {
		$.fn.zTree.init($("#zTree"), setting, zNodes);
		zTree = $.fn.zTree.getZTreeObj("zTree");
	});
	function getFont(treeId, node) {
		return node.font ? node.font : {};
	}
	function setRsAndChech() {
		var checkedNodes = zTree.getCheckedNodes(true);
		var arrayIds = new Array();
		for ( var i in checkedNodes) {
			arrayIds.push(checkedNodes[i].id);
		}
		if(arrayIds.length!=0){
			$("#menuIds").val(arrayIds.join(","));
		}else{
			alert("请选择资源！");
			return false;
		}
	}
	$(document).ready(function() {
		$("#div1").css({
			"left" : $("#tab1").width() + 60,
			"position" : "absolute",
			"width" : "350px",
			"float" : "right"
		});
	});
</script>
<style type="text/css">
div.zTreeDemoBackground {
	width: 350px;
	height: 340px;
	text-align: left;
}

ul.ztree {
	margin-top: 10px;
	width: 300px;
	height: 320px;
	overflow-y: scroll;
	overflow-x: auto;
}
</style>
</head>
<body>
	<%-- <%@ include file="/WEB-INF/view/common/topbar.jsp"%> --%>
	<div class="main-container" id="main-container">
		<div class="main-container-inner">
			<%-- <%@ include file="/WEB-INF/view/common/topbar.jsp"%> --%>
			<div class="main-content" style="margin-left: 0px;">
				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb" style="margin-left: 4px;">
						<li><i class="icon-home home-icon"></i>首页</li>
						<li>通用模块</li>
						<li>角色管理</li>
						<li class="active">修改权限</li>
					</ul>
				</div>
				<div class="page-content">
					<form action="${ctx}/pub/sysmgr/authmgr/update_right.do" method="post" class="form-horizontal"
						id="inputForm">
						<input type="hidden" name="backurl" value="${backurl}" />
						<input type="hidden" name="id" value="${authRight.id}"/>
						<input type="hidden" name="menuIds" value="" id="menuIds"/>
						<div class="row">
							<div class="col-xs-4">
								<div class="widget-box" style="border-bottom:1px solid #FFFFFF;">
									<div id="operation_div">
										<div class="table-responsive"></div>
									</div>
									<div class="form-group">
										<div class="col-sm-3 control-label no-padding-right"
											for="form-field-1">权限名称 *</div>
										<div class="col-sm-9">
											<input type="text" name="rightName" id="rightName"
												value="${authRight.rightName}" class="col-xs-10 col-sm-8" 
												maxlength="200" require="true" value=""
												datatype="require|limit|ajax|safeString2" min="1" max="200"
												msg="请填写权限名称！|权限名称最多100个英文字符!|权限名称已经被占用！|不允许输入特殊字符"
												url="${ctx}/pub/sysmgr/authmgr/check_right_name.do" oldValue=""
												title="必填项,1-200个字符，允许中文，英文字母、数字和符号" /> <label
												id="success_rightName" style="display:none;"><span
												class="ico_cue_ok"></span> </label> <label class="error_rightName"
												style="display:none;" for="rightName"><span
												class="ico_cue_no"></span> <span class="alert-error"
												id="error_rightName"></span> </label>
										</div>
									</div>
									<div class="space-4"></div>
									<div class="form-group">
										<div class="col-sm-3 control-label no-padding-right"
											for="form-field-1">权限类型*</div>
										<div class="col-sm-9">
											<select name="type" id="type" require="true" datatype="require" msg="请选择权限类型！"
												class="col-xs-10 col-sm-8" >
												<option value="">-请选择-</option>
												${cm:ctoption('authusertype',authRight.type)}
											</select>
										</div>
									</div>
									<div class="space-4"></div>
									<div class="form-group">
										<div class="col-sm-3 control-label no-padding-right"
											for="form-field-1">状态*</div>
										<div class="col-sm-9">
											<select name="roleStatus" id="roleStatus"
												class="col-xs-10 col-sm-8" >
												${cm:ctoption2('entity_status',authRight.status,'9')}
											</select>
										</div>
									</div>
									<div class="space-4"></div>
									<div class="form-group">
										<div class="col-sm-3 control-label no-padding-right"
											for="form-field-1">描述：</div>
										<div class="col-sm-9">
											<textarea class="col-xs-15 col-sm-8" max="400" name="remark">${authRight.remark}</textarea>
										</div>
									</div>
									<div class="clearfix form-group">
										<div class="col-md-offset-3 col-md-3">
											<button type="submit" class="btn btn-sm btn-success" id="sbmBtn"><i class="icon-ok bigger-110"></i>提交</button>
										</div>
										<div>
											<button type="button" class="btn btn-sm btn-info" id="returnBtn" onclick="javascript:history.go(-1);"><i class="icon-arrow-left bigger-110"></i>返回</button>
								 		</div>
									</div>
								</div>
							</div>

							<div class="col-xs-8">
								<div class="widget-box">
									<div class="widget-header widget-header-flat">
										<h5 class="smaller lighter">选择资源权限</h5>
									</div>
									<div class="widget-body">
										<div class="widget-main">
											<div class="row mg-top12"
												style="overflow:auto; height: 400px; border-top:1px solid #CCCCCC;">
												<div id="zTree" class="ztree"></div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
				</div>
			</div>
			</form>
		</div>
	</div>
</body>
</html>
